{template 'public/header'}

{template 'public/comhead'}

<link rel="stylesheet" type="text/css" href="../addons/yzzc_sun/template/public/ygcsslist.css">
<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>
    <li  {if $type=='all'} class="active" {/if}><a href="{php echo $this->createWebUrl('storelist',array('type'=>all));}">全部车辆</a></li>
</ul>
<br>
<div class="row ygrow">
    <div class="col-lg-12">
        <form action="" method="get" class="col-md-4">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="yzzc_sun" />
            <input type="hidden" name="do" value="branchslist" />
            <div class="input-group">
                <input type="text" name="keywords" class="form-control" placeholder="请输入车辆号">
                <span class="input-group-btn">
                    <input type="submit" class="btn btn-default" name="submit" value="查找"/>
                </span>
            </div>
            <input type="hidden" name="token" value="{$_W['token']}"/>
        </form>

        <div class="col-md-4">
            <input type="hidden" name="token" value="{$_W['token']}"/>
        </div>
    </div><!-- /.col-lg-6 -->
</div>

<div class="row ygrow">
    <div class='col-lg-12'>
        <a  href="{php echo $this->createWebUrl('storelist',array('op'=>add));}"><button class="btn btn-sm store-blue">添加车辆</button></a>
    </div>
</div>
<div class="main ">

    <div class="panel panel-default">
        <div class="panel-heading">
            门店列表
        </div>
        <div class="panel-body" style="padding: 0px 15px;">
            <div class="row" id="accordion">
                <table class="yg5_tabel col-md-12">
                    <tr class="yg5_tr1">
                        <td  class="store_td1 col-md-1">编号</td>
                        <td class="col-md-1">车辆名称</td>
                        <td class="col-md-1">所属门店</td>
                        <td class="col-md-1">车牌号</td>
                        <td class="col-md-1">颜色/车身结构/排量/变速箱/核载人数</td>
                        <td class="col-md-1">租金</td>
                        <td  class="col-md-1">备注</td>
                        <td class="col-md-1">申请状态</td>
                        <td class="col-md-1">创建时间</td>
                        <td>操作</td>
                    </tr>

                    {loop $info $key $item}
                    <tbody>
                    <tr class="yg5_tr2" >
                        <td>{$item['car_id']}</td>
                        <td>{$item['car_name']}</td>
                        <td>{$item['mobile']}</td>
                        <td>{$item['car_num']}</td>
                        <td>{$item['colour']} / {if $item['structure'] == 1}两厢
                            {elseif $item['structure'] == 2}三厢{/if} / {if $item['grarbox'] == 1}手动挡
                            {elseif $item['grarbox'] == 2}自动挡{/if} / {$item['displacement']} / {$item['num']}人</td>
                        <td>{$item['money']}</td>
                        <td>{$item['remark']}</td>
                        <td>
                            {if $item['status']==0}
                            <span class="label store-yellow btn btn-sm">审核中</span>
                            {elseif $item['status']==1}
                            <span class="label store-green btn btn-sm">审核通过</span>
                            {elseif $item['status']==2}
                            <span class="label store-green btn btn-sm">上架</span>
                            {elseif $item['status']==3}
                            <span class="label store-red btn btn-sm">审核失败</span>
                            {elseif $item['status']==4}
                            <span class="label store-disable btn btn-sm">下架</span>
                            {/if}
                        </td>
                        <td>{$item['createtime']}</td>
                        <td>
                            {if $item['status']==0}
                            <a class="btn btn-xs store-green" href="{php echo $this->createWebUrl('storecar', array('car_id' => $item['car_id'],'op'=>change,'status'=>1))}">
                                审核通过
                            </a>
                            <a href="javascript:void(0);" class="btn btn-xs store-red" data-toggle="modal" data-target="#myModal{$item['car_id']}">
                                审核失败
                            </a>
                            {elseif $item['status'] == 1}
                            <a class="btn btn-xs store-green" href="{php echo $this->createWebUrl('storecar', array('car_id' => $item['car_id'],'op'=>shelves))}">
                                上架
                            </a>
                            <a href="javascript:void(0);" class="btn btn-xs store-red" data-toggle="modal" data-target="#myModal{$item['car_id']}">
                                审核失败
                            </a>
                            {elseif $item['status'] == 2}
                            <a class="btn btn-xs store-red" href="{php echo $this->createWebUrl('storecar', array('car_id' => $item['car_id'],'op'=>change,'status'=>4))}">下架</a>
                            {elseif $item['status'] == 3}
                            <a class="btn btn-xs store-green" href="{php echo $this->createWebUrl('storecar', array('car_id' => $item['car_id'],'op'=>change,'status'=>1))}">
                                审核通过
                            </a>
                            {elseif $item['status'] == 4}
                            <a class="btn btn-xs store-green" href="{php echo $this->createWebUrl('storecar', array('car_id' => $item['car_id'],'op'=>shelves,'status'=>1))}">
                                上架
                            </a>
                            {/if}

                            <a href="{php echo $this->createWebUrl('goodsinfo', array('id' => $item['id']))}" class="storespan btn btn-xs">
                                <span class="fa fa-pencil"></span>
                                <span class="bianji">编辑
                                    <span class="arrowdown"></span>
                                 </span>
                            </a>

                            <!--<a href="javascript:;" class="storespan btn btn-xs" onclick="del({$item['car_id']})">
                                <span class="fa fa-trash-o"></span><span class="bianji">删除<span class="arrowdown"></span></span>
                            </a>-->
                        </td>
                    </tr>
                    </tbody>
                    <div class="modal fade" id="myModal{$item['car_id']}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title" id="myModalLabel" style="font-size: 20px;">拒绝备注</h4>
                                </div>
                                <form action="" method="get" >
                                    <input type="hidden" name="c" value="site" />
                                    <input type="hidden" name="a" value="entry" />
                                    <input type="hidden" name="m" value="yzzc_sun" />
                                    <input type="hidden" name="do" value="storecar" />
                                    <input type="hidden" name="car_id" value="{$item['car_id']}" />
                                    <input type="hidden" name="op" value="change" />
                                    <input type="hidden" name="status" value="3" />
                                    <div class="modal-body" style="font-size: 20px">
                                        <input type="text" name="remark" placeholder="拒绝理由" class="form-control"/>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                        <input type="submit" class="btn btn-info" name="submit" value="确定"/>
                                    </div>
                                    <input type="hidden" name="token" value="{$_W['token']}"/>
                                </form>
                            </div>
                        </div>
                    </div>
                    {/loop}
                    {if empty($item)}
                    <tr class="yg5_tr2">
                        <td colspan="8">
                            暂无地址信息
                        </td>
                    </tr>
                    {/if}
                </table>
            </div>
        </div>

    </div>
    </form>
</div>
<script type="text/javascript">
    $(function(){
        $("#frame-16").show();
        $("#yframe-16").addClass("wyactive");
    })
    function del(id) {
        var ret = confirm("删除前请确认该门店所有车辆均已下架，您确定删除吗？")
        if (ret==true){
            $.ajax({
                type:"POST",
                url:"{php echo $this->createWebUrl('branchslist',array('op'=>delete))}",
                dataType:"JSON",
                data:{id:id},
                success:function(res){
                    console.log(res);
                    location.reload();
                    // if(res.status == 1) {
                    //     layer.msg(res.message, {icon: 1});
                    //     location.href ="{php echo $this->createWebUrl('renting')}";
                    // }else{
                    //     layer.msg(res.message, {icon: 6});
                    //     location.href =res.url;
                    // }
                }
            })
        }
    }
</script>